﻿using System;
using System.Reflection;
using System.Runtime.Serialization;

namespace Cubicle.Core.DataContracts
{
    [DataContract]
    [Serializable]
    public class ParameterData
    {
        public ParameterData() {}
        public ParameterData(int id, ParameterInfo pi)
        {
            Id = id;
            Name = pi.Name;
            ParameterType = pi.ParameterType.FullName ?? pi.ParameterType.Name;
        }

        [DataMember]
        public int Id { get; set; }
        
        [DataMember]
        public string Name { get; set; }

        [DataMember]
        public string ParameterType { get; set; }

        public static ParameterData Create(int i, ParameterInfo p)
        {
            var pData = new ParameterData();
            pData.Id = i;
            pData.Name = p.Name;
            pData.ParameterType = p.ParameterType.FullName ?? p.ParameterType.Name;
            return pData;
        }

    }
}